package com.mall.controller;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.mall.bean.Goods;
import com.mall.bean.User;
import com.mall.service.IAllGoodsService;

@Controller
public class AllGoodsController {

	@Resource
	private IAllGoodsService allGoodsService;


	//点击商品的种类时
	@RequestMapping("showClassify-all")
	public String findClassify(@Param("requestName") String requestName, @Param("classify") String classify, Goods goods, Model model, HttpSession session) {
		User user = (User) session.getAttribute("user");
		model.addAttribute("user", user);

		goods.setGoods(classify);
		goods.setGoods_type(classify);
		List<Goods> goodsAll = allGoodsService.findAllClassify(goods);

		model.addAttribute("goodsAll", goodsAll);
		return "idle-goods-1";
	}

	//点击全部时
	@RequestMapping("showGoodsAll")
	public String findAllGoods(Goods goods, Model model, HttpSession session) {
		User user = (User) session.getAttribute("user");
		model.addAttribute("user", user);
		List<Goods> goodsAll = allGoodsService.findAllGoods(goods);
		model.addAttribute("goodsAll", goodsAll);
		return "idle-goods-1";
	}


}
